package com.example.industry.controller;

import com.example.industry.service.InviteService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/invite")
public class InviteController
{
    @Resource
    private InviteService inviteService;

    /**
     * 发送邀请
     * @param projectId 项目Id
     * @param email 收件人邮箱
     * @return 是否成功
     */
    @PostMapping(value = "/send")
    public boolean sendInvite(@RequestParam(value = "projectId") Integer projectId,
                              @RequestParam(value = "email") String email)
    {
        return inviteService.sendInvite(projectId, email);
    }

    /**
     * 接受邀请
     * @param projectId 邀请Id
     * @param userId 被邀请的用户Id
     * @return 是否成功
     */
    @GetMapping(value = "/accept")
    public boolean acceptInvite(@RequestParam(value = "projectId") Integer projectId,
                                @RequestParam(value = "userId") Integer userId)
    {
        return inviteService.acceptInvite(projectId, userId);
    }
}
